﻿using System;
using System.Collections.Generic;
using Lottery.App.Model;

namespace Lottery.App.DAL
{
    public class A3Dao : ResultDao<A3Info>
    {
        internal override IList<RecordInfo> List(string value)
        {
            const string hql = "from RecordInfo where A3 = ?";

            return Session.CreateQuery(hql)
                .SetString(0, value)
                .List<RecordInfo>();
        }

        protected override int GetLastID(string value)
        {
            string hql = "select Max(r.id) from RecordInfo r where A3 = ?";

            return Session.CreateQuery(hql)
                .SetString(0, value)
                .UniqueResult<int>();
        }

        protected override IList<A3Info> GetItems(RecordInfo record)
        {
            const string hql = "from A3Info where Value = ?";

            return Session.CreateQuery(hql)
                .SetString(0, record.A3)
                .List<A3Info>();
        }

        public override IList<int> GetIds(string value)
        {
            const string hql = "select r.id from RecordInfo r where A3 = ?";

            return Session.CreateQuery(hql)
                .SetString(0, value)
                .List<int>();
        }

    }
}
